@echo off

set CMD=%~n0%~x0
set DIR=%~d0%~p0
set ARG=%1

if "%ARG%"=="" (
	set BIN_DIR=C:\BIN\
) else (
	goto _end_
	if "%ARG%"=="--help" (
		echo install - Install Command Utilities
		echo usage: install [DESTINATION DIR]
		goto _end_
	) else (
		set BIN_DIR=%ARG%
	)
)

if not exist "%BIN_DIR%" mkdir "%BIN_DIR%"
echo Install utilities to "%BIN_DIR%"

for %%i in (%DIR%\*.exe %DIR%\*.bat %DIR%\*.vbs %DIR%\*.rb) do (
	if not "%CMD%" == "%%~ni%%~xi" (
		echo Install %%~ni%%~xi
		copy %%i %BIN_DIR%
	)
)

pushd %DIR%\src\
for /R %%i in (*.exe) do (
	echo Install %%~ni%%~xi
	copy %%i %BIN_DIR%
)
popd

:_end_
